package com.ubb.damate.jasper.datasource;

import java.util.List;
import java.util.Map;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

public class EclipseUsageDataSource implements JRDataSource {

	private int index;
	private List<Map<String, Object>> fields;
	
	public EclipseUsageDataSource(List<Map<String, Object>> fields) {
		this.fields = fields;
		this.index = -1;
	}
	
	@Override
	public Object getFieldValue(JRField field) throws JRException {
		if (field.getName().equals("user")) {
			return fields.get(index).get("user");
		} else {
			return (Double)fields.get(index).get(field.getName());
		}
	} 
	
	

	@Override
	public boolean next() throws JRException {
		index++;
		return index < fields.size();
	}

}
